const Cesium=window.Cesium
import  "./ElectricMaterialProperty4Ellipsoid.js";

export default class Lighting{
 _viewer:any
 _entity:any
 _entities:Array<any>
constructor(viewer:any){
this._viewer=viewer
this._entity=null
this._entities=[]
}

create(option:any){
    
    let viewer=this._viewer
    if(!this._entity){
        this._entity= viewer.entities.add({
            position:option.position ,
            ellipsoid: {
              radii: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0),
              material: new Cesium.ElectricMaterialProperty4Ellipsoid({
                color: new Cesium.CallbackProperty(function () {
                  return Cesium.Color.PURPLE;
                }, false),
                speed: 2.0,
              }),
            },
          });
    }else{
        this._entity.show=true 
    }

    viewer.flyTo(viewer.entities);
    this._entities.push(this._entity)
}
unshow(){
    this._entity.show=false
}
destroyAll(){
  this._entities.forEach((e)=>{
    this._viewer.remove(e)
  })
}
}